package com.motorola.examples;

import javax.naming.InitialContext;

import com.ibm.websphere.asynchbeans.WorkManager;

public class ServiceLocator {

	private static String wmJNDIName = "java:comp/env/wm/DefaultWorkManager";
	static WorkManager wm = null;

	public static WorkManager getWorkManager() {

		if (wm == null) {
			try {
				InitialContext ctx = new InitialContext();
				wm = (WorkManager) ctx.lookup(wmJNDIName);
				System.out.println("WorkManager obtained");

			} catch (Exception ex) {
				System.out.println("Unable to lookup workmanager: "
						+ ex.getMessage());
			}
		}

		return wm;
	}

}
